const {ccclass, property} = cc._decorator;

@ccclass
export default class objectLayerMgr extends cc.Component {
    
    private objectList:cc.Node[];
    private updateInterval:number = 0.1;
    private updateTimer:number = 0;

    onLoad(){
        this.objectList = [];
    }

    update (dt) {
        this.updateTimer += dt;
        if (this.updateTimer < this.updateInterval) return;

        this.objectList = this.node.children;   
        this.objectList.sort(function(a,b){
            return b.y - a.y;
        });

        for(var index = 0, len = this.objectList.length; index < len; index++){
            this.objectList[index].zIndex = index;
        }
    }
}
